/**
 * 
 */
package com.music.profile.filter;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author spradeep
 *
 */
public class LoginRequiredFilter implements Filter {
	private String someString;
	
	private static final Logger log = Logger.getLogger(LoginRequiredFilter.class.getName());
	/* (non-Javadoc)
	 * @see javax.servlet.Filter#destroy()
	 */
	public void destroy() {
		log.info("Login Required filter destroying");
		// Do nothing.
	}

	/* (non-Javadoc)
	 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
	 */
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		HttpServletRequest req = (HttpServletRequest)request;
		HttpServletResponse res = (HttpServletResponse)response;
		log.info("Login Required Filter");
		// Check whether user is logged in.
		chain.doFilter(request, response);
	}

	/* (non-Javadoc)
	 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
	 */
	public void init(FilterConfig arg0) throws ServletException {
		log.info("Login Required filter initializing");
		// no initialising now.
	}

	public void setSomeString(String someString) {
		log.info("Setting string");
		this.someString = someString;
	}

	public String getSomeString() {
		return someString;
	}

}
